package com.hailian.fintech.hlpictureserver.controller;


import com.hailian.fintech.hlcomm_interfaceserver.result.ResultInfo;
import com.hailian.fintech.hlcomm_interfaceserver.util.File_Utils;
import com.hailian.fintech.hlpictureserver.entity.Picture;
import com.hailian.fintech.hlpictureserver.service.IPictureService;
import com.sun.org.apache.xml.internal.resolver.helpers.PublicId;
import lombok.extern.slf4j.Slf4j;
import org.omg.CORBA.PRIVATE_MEMBER;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wk
 * @since 2020-05-20
 */
@RestController
@RequestMapping("/picture")
@Slf4j
public class PictureController {
    @Autowired
    private IPictureService iPictureService;
    @RequestMapping("upload")
    public Object upload(@RequestBody MultipartFile file ) throws IOException {
        //log.info("============",file);
        String processFile = File_Utils.processFile(file);
        return new ResultInfo().success(processFile);
    }
    @RequestMapping("insertPic")
    public Object insertPic(@RequestBody Picture pic)  {
        //log.info("============",file);
        boolean falg = iPictureService.saveOrUpdate(pic);
        return new ResultInfo().success(falg);
    }

}

